home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / powerd / lib / chunky.lha / chunky / CopyChunkyMask.ass < prev    next >
Encoding:
Text File  |  1980-08-04  |  1.7 KB  |  80 lines

  1. ; CopyChunkyMask(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5,d6)
  2.  
  3.     machine    mc68020
  4.  
  5.     xdef    _CopyChunkyMask
  6. _CopyChunkyMask
  7.     movem.l    d2-d7/a2-a3,-(a7)
  8.  
  9. ; DESTINATION BOUNDS
  10.     tst.l    d0        ; left bound
  11.     bge.s    .leftdone
  12.     move.l    d0,d7            ; store left negative offset
  13.     neg.l    d7
  14.     cmp.l    d4,d7
  15.     bge.s    .finish            ; out of bounds
  16.     moveq    #0,d0            ; left position
  17.     add.l    d7,d2
  18.     sub.l    d7,d4            ; new width
  19. .leftdone
  20.     tst.l    d1        ; top bound
  21.     bge.s    .topdone
  22.     move.l    d1,d7            ; store top negative offset
  23.     neg.l    d7
  24.     cmp.l    d5,d7
  25.     bge.s    .finish            ; out of bounds
  26.     moveq    #0,d1            ; top position
  27.     add.l    d7,d3
  28.     sub.l    d7,d5            ; new height
  29. .topdone
  30.     cmp.l    (a0),d0        ; right bound
  31.     bgt.s    .finish
  32.     move.l    (a0),d7            ; store maximal width
  33.     sub.l    d0,d7            ; change width
  34.     cmp.l    d4,d7            ; check if we can fit
  35.     bgt.s    .rightdone        ; we can fit
  36.     move.l    d7,d4            ; new width, we can't fit
  37. .rightdone
  38.     cmp.l    (4,a0),d1        ; bottom bound
  39.     bgt.s    .finish
  40.     move.l    (4,a0),d7            ; store maximal width
  41.     sub.l    d1,d7            ; change width
  42.     cmp.l    d5,d7            ; check if we can fit
  43.     bgt.s    .bottomdone        ; we can fit
  44.     move.l    d7,d5            ; new width, we can't fit
  45. .bottomdone
  46.  
  47.     move.l    (a0),d7        ; get dest width to d6
  48.     muls.l    d1,d7
  49.     add.l    d7,d0        ; now we have start position in dest buffer
  50.     move.l    (8,a0),a2
  51.     add.l    d0,a2
  52.  
  53.     move.l    (a1),d7
  54.     muls.l    d3,d7
  55.     add.l    d7,d2
  56.     move.l    (8,a1),a3
  57.     add.l    d2,a3        ; and start position in source buffer
  58.  
  59.     move.l    (a0),d2        ; get the d2 and d3 values
  60.     sub.l    d4,d2
  61.     move.l    (a1),d3
  62.     sub.l    d4,d3
  63.  
  64.     subq.l    #1,d4
  65.     subq.l    #1,d5
  66.     move.l    d4,d7        ; store width
  67. .loopy    move.l    d7,d4        ; restore width
  68. .loopx    move.b    (a3)+,d0        ; get source colour
  69.     cmp.b    d6,d0
  70.     bne.s    .noskip
  71.     addq.l    #1,a2
  72.     bra.s    .skip
  73. .noskip    move.b    d0,(a2)+        ; copy pixel
  74. .skip    dbra.s    d4,.loopx
  75.     adda.l    d2,a2
  76.     adda.l    d3,a3
  77.     dbra.s    d5,.loopy
  78. .finish    movem.l    (a7)+,d2-d7/a2-a3
  79.     rts
  80.